package cn.dapeng.linked;

/**
 * @BelongProject study
 * @BelongPackage cn.dapeng.linked
 * @Description 反转单链表
 * @ClassName ReverseLinkedNode
 * @Author xupenghong
 * @Date 2024/9/3 14:43
 * @Version 1.0.0
 */
public class ReverseLinkedNode {

    public static LinkedNode reverse(LinkedNode head) {
        LinkedNode next = head, pre = null;
        while (head != null) {
            head = head.next;

            next.next = pre;
            pre = next;

            next = head;
        }
        return pre;
    }

}
